package com.ihg.hiex.admin.entity.search;

import java.util.Map;

import com.demo2do.core.persistence.support.QueryBuilder;
import com.demo2do.core.persistence.support.QueryFilter;
import com.demo2do.core.persistence.support.QueryOrder;

public class SessionReportSearch implements QueryBuilder {

    private Long session;

    private Long delegate;

    /**
     * filter
     */
    private QueryFilter filter;

    /**
     * order
     */
    private QueryOrder order;

    public SessionReportSearch() {

    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getPreparedFilter(
     * boolean)
     */
    public QueryFilter getPreparedFilter(boolean refresh) {
        if (filter == null || refresh) {

            filter = new QueryFilter().addEquals("session.id", session)
                                      .addEquals("delegate.id", delegate);
        }
        return filter;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#getOrder()
     */
    public QueryOrder getOrder() {

        return order;
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * com.demo2do.core.persistence.support.QueryBuilder#buildSentenceTemplate()
     */
    public String buildSentenceTemplate() {

        String sentence = "FROM SessionReport WHERE disabled = false" + getPreparedFilter(false).clauseSentence();

        return sentence;
    }

    /*
     * (non-Javadoc)
     * 
     * @see com.demo2do.core.persistence.support.QueryBuilder#buildParameters()
     */
    public Map<String, Object> buildParameters() {

        return getPreparedFilter(false).parameters();
    }

    /**
     * @return
     */
    public QueryFilter getFilter() {
        return filter;
    }

    /**
     * @param order
     */
    public void setOrder(QueryOrder order) {
        this.order = order;
    }

    /**
     * @return the session
     */
    public Long getSession() {
        return session;
    }

    /**
     * @return the delegate
     */
    public Long getDelegate() {
        return delegate;
    }

    /**
     * @param session the session to set
     */
    public void setSession(Long session) {
        this.session = session;
    }

    /**
     * @param delegate the delegate to set
     */
    public void setDelegate(Long delegate) {
        this.delegate = delegate;
    }

}
